package com.ruleengine.parser.impl;

import java.util.List;

import org.dom4j.Element;

import com.ruleengine.parser.ITaskParser;
import com.ruleengine.parser.exception.RuleEngineParserException;
import com.ruleengine.task.config.TaskConfigManager;
import com.ruleengine.task.impl.ComplexTask;

public class ComplexTaskParser<E extends ComplexTask> extends BaseTaskParser<E> {

    @Override
    public E parseTask(Element ele, E task)
            throws RuleEngineParserException {
        // TODO Auto-generated method stub
      //解析组内的子工作流节点
        List<Element> children = ele.elements();
        if(children!=null){
            for(Element child : children){
                if(!TaskConfigManager.getInstance().isWorkflowElement(child.getName()))
                    //节点不是工作流节点
                    continue;
                //解析子工作流节点
                ITaskParser parser = TaskConfigManager.getInstance().getTaskParser(child.getName());
                task.addSubTask(parser.parse(child));
            }
        }
        
        return task;
    }

}
